package com.fire.controller;

import com.fire.transaction.api.dto.PlatformChannelDTO;
import com.fire.transaction.api.dto.com.fire.transaction.api.PayChannelService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**平台支付参数配置相关的controller
 * @author fire
 * @date 2021年07月21日17:27
 */
@RestController
@Api(value = "商户平台--渠道与支付参数相关",tags = "商户平台-渠道与支付参数",description ="商户平台-渠道与支付参数")
@Slf4j
public class PlatformParamController {

    @DubboReference
    private PayChannelService payChannelService;

    @ApiOperation("获取平台服务类型")
    @GetMapping("/my/platform-channels")
    public List<PlatformChannelDTO> queryPLatformChannel(){
        return payChannelService.queryPlatformChannel();
    }
    @ApiOperation("绑定服务类型")
    @PostMapping("/my/apps/{appId}/platform-channels")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "应用id",name = "appId",dataType = "string",paramType = "path"),
            @ApiImplicitParam(value = "服务类型code",name = "platformChannelCodes",dataType = "string",paramType = "query")
    })
    public void bindPlatformForApp(@PathVariable("appId") String appId, @RequestParam("platformChannelCodes") String platformChannelCodes){
        payChannelService.bindPlatformChannelForApp(appId,platformChannelCodes);
    }

    @ApiOperation("查询应用是否绑定了某个服务类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "appId", value = "应用appId", required = true, dataType =
                    "String", paramType = "query"),
            @ApiImplicitParam(name = "platformChannel", value = "服务类型", required = true, dataType =
                    "String", paramType = "query")
    })
    @GetMapping("/my/merchants/apps/platformchannels/")
    public int queryAppBindPlatformChannel(@RequestParam String appId, @RequestParam String
            platformChannel){
        return payChannelService.queryAppBindPlatformChannel(appId, platformChannel);
    }
}
